 ///
 /// @file    nestedTemplate2.cc
 /// @author  lemon(haohb13@gmail.com)
 /// @date    2016-03-07 16:04:28
 ///

//				实例化
//函数模板/类模板 -->  模板函数/模板类
 
#include <iostream>
using std::cout;
using std::endl;

template <typename T>
class OutSide
{
public:
	template <class R>
	class Inside
	{
	public:
		Inside(R x)
		: _r(x)
		{
			cout << "Inside()" << endl;
		}
		void display();
#if 0
		{
			cout << "Inside:" << _r << endl;
		}
	#endif

	private:
		R _r;
	};
public:
	OutSide(T x)
	: _t(x)
	{
		cout << "OutSide() " << endl;
	}

	void display();
#if 0
	{
		cout << "OutSide:";
		_t.display();
	}
#endif

private:
	Inside<T> _t;
};


template <typename T>
template <typename R>
void OutSide<T>::Inside<R>::display()
{
	cout << "Inside:" << _r << endl;
}

template <typename T>
void OutSide<T>::display()
{
	cout << "OutSide:";
	_t.display();
}

int main(void)
{
	OutSide<int>::Inside<double> obin(3.5);
	obin.display();

	OutSide<int> obout(2);
	obout.display();

	return 0;
}
